﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Pg.BioMedics.SDR.ServiceAgents.Configuration
{
    /// <summary>
    /// Represents ServiceAgents configuration section
    /// </summary>
    public sealed class ServiceAgentsSection : ConfigurationSection
    {
        #region Constants

        private const string SectionName = "serviceAgentsSettings";
        private const string ServicesProperty = "services";

        #endregion

        #region Properties

        /// <summary>
        /// Gets / sets services configuration element embedded in this section
        /// </summary>
        [ConfigurationProperty(ServicesProperty)]
        public ServicesElementCollection Services
        {
            get
            {
                return this[ServicesProperty] as ServicesElementCollection;
            }

            set
            {
                this[ServicesProperty] = value;
            }
        }

        #endregion

        #region Static methods

        /// <summary>
        /// Loads instance of this configuration section form configuration file
        /// </summary>
        /// <returns></returns>
        public static ServiceAgentsSection GetConfiguration()
        {
            return ConfigurationManager.GetSection(SectionName) as ServiceAgentsSection ?? new ServiceAgentsSection();
        }

        #endregion
    }
}
